package com.SMP.controller.meet_room;

import com.SMP.model.MeetSubscribePerson;
import com.SMP.model.Msg;
import com.SMP.service.meet_room.MeetSubscribePersonService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.Valid;
import java.util.List;

@Controller
public class MeetSubscribePersonConfigController {
    /**
     * @author SY
     */
    @Autowired
    MeetSubscribePersonService meetSubscribePersonService;

    /**
     * @author SY
     * //* @param  添加会议人员
     */
    @RequestMapping("/addMeetingStaff")
    @ResponseBody
    public Msg addMeetSubscribePerson(@Valid MeetSubscribePerson meetSubscribePerson) {
        int a = meetSubscribePersonService.addMeetSubscribePerson(meetSubscribePerson);
        if (a == 1) {
            return Msg.success();
        } else {
            return Msg.fail();
        }
    }
    /**
     * @author SY
     * //* @param  修改会议人员
     */
    @RequestMapping("/updMeetingStaff")
    @ResponseBody
    public Msg updMeetSubscribePerson(@Valid MeetSubscribePerson meetSubscribePerson) {
        int a = meetSubscribePersonService.updMeetSubscribePerson(meetSubscribePerson);
        if (a == 1) {
            return Msg.success();
        } else {
            return Msg.fail();
        }
        /**
         * @author SY
         *
        //* @param  查询所有会议人员
         */
    }
            @RequestMapping("/selAllMeetingStaff")
        @ResponseBody
        public Msg selAllMeetSubscribePerson(@RequestParam(value = "pn") Integer pn) {
            PageHelper.startPage(pn, 10);
            List<MeetSubscribePerson> list=meetSubscribePersonService.selAllMeetSubscribePerson();
            PageInfo<MeetSubscribePerson> page = new PageInfo<MeetSubscribePerson>(list, 5);
            return Msg.success().add("pageInfo", page);
        }
    /**
     * @author SY
     *
    //* @param  查询单个会议人员
     */
    @RequestMapping("/selMeetingStaff")
    @ResponseBody
    public Msg selMeetSubscribePerson(@RequestParam(value="person_name",defaultValue = "1")String id) {
        MeetSubscribePerson meetSubscribePerson=meetSubscribePersonService.selMeetSubscribePerson(id);
        return Msg.success().add("meetSubscribePerson",meetSubscribePerson);


    }
    /**
     * @author SY
    //	 * @param 删除单个会议人员
     * */
    @RequestMapping("/delMeetingStaff")
    @ResponseBody
    public Msg delMeetSubscribePerson(@RequestParam(value = "subscribe_id",defaultValue = "1")String subscribe_id){

       int a=meetSubscribePersonService.delMeetSubscribePerson(subscribe_id);
        if(a==1){
            return Msg.success();
        }else {
            return Msg.fail();
        }
    }
}